﻿using System;
using System.Windows;
using ComplexNumberPresentation;
using Logger;
using ComplexNumberLibrary;

namespace WPFClient
{
    public partial class MainWindow : Window, IView
    {
        public MainWindow()
        {
            InitializeComponent();
            new Presenter(this);
        }


        public ComplexNumber Result { get; set; }
        public double CurrentReal
        {
            get { return Convert.ToDouble(realValue.Text); }
            set { realValue.Text = Convert.ToString(value); }
        }
        public double CurrentImaginary
        {
            get { return Convert.ToDouble(imageValue.Text); }
            set { imageValue.Text = Convert.ToString(value); }
        }
        public bool ImaginaryFocused
        {
            get;
            set;
        }
        public String ImaginaryText
        {
            get { return imageButton.Content.ToString(); }
            set { imageButton.Content = value; }
        }

        public bool LogVisible
        {
            set { Log.Visibility = value ? Visibility.Visible : Visibility.Hidden; }
            get { return Log.Visibility == Visibility.Visible; }
        }
        public String LogText
        {
            set { Log.Text = value; }
            get { return Log.Text; }
        }
        public int LoggerIndex
        {
            set { LoggerSwitcher.SelectedIndex = value; }
            get { return LoggerSwitcher.SelectedIndex; }
        }

        public Operation CurrentOperation { get; set; }
        public string ErrorMessage { set; get; }

        public event Action OnClearClick;
        public event Action OnAllClearClick;
        public event Action OnOneClick;
        public event Action OnTwoClick;
        public event Action OnThreeClick;
        public event Action OnFourClick;
        public event Action OnFiveClick;
        public event Action OnSixClick;
        public event Action OnSevenClick;
        public event Action OnEightClick;
        public event Action OnNineClick;
        public event Action OnZeroClick;
        public event Action OnImaginaryClick;
        public event Action OnResultClick;
        public event Action OnAddClick;
        public event Action OnSubtractClick;
        public event Action OnMultiplyClick;
        public event Action OnDivideClick;
        public event Action OnModulusClick;
        public event Action OnShowLogClick;
        public event Action OnSaveToFileClick;
        public event Action<int> OnChooseLogClick;

        public ILogger getLoggerToFile()
        {
            return new LoggerToFile();
        }

        public ILogger getHtmlLogger()
        {
            return new HtmlLogger();
        }

        private void clearButton_Click(object sender, RoutedEventArgs e)
        {
            OnClearClick();
        }

        private void clearAllButton_Click(object sender, RoutedEventArgs e)
        {
            OnAllClearClick();
        }

        private void imageButton_Click(object sender, RoutedEventArgs e)
        {
            OnImaginaryClick();
        }

        private void modulusButton_Click(object sender, RoutedEventArgs e)
        {
            OnModulusClick();
        }

        private void sevenButton_Click(object sender, RoutedEventArgs e)
        {
            OnSevenClick();
        }

        private void eightButton_Click(object sender, RoutedEventArgs e)
        {
            OnEightClick();
        }

        private void nineButton_Click(object sender, RoutedEventArgs e)
        {
            OnNineClick();
        }

        private void addButton_Click(object sender, RoutedEventArgs e)
        {
            OnAddClick();
        }

        private void fourButton_Click(object sender, RoutedEventArgs e)
        {
            OnFourClick();
        }

        private void fiveButton_Click(object sender, RoutedEventArgs e)
        {
            OnFiveClick();
        }

        private void sixButton_Click(object sender, RoutedEventArgs e)
        {
            OnSixClick();
        }

        private void subtractButton_Click(object sender, RoutedEventArgs e)
        {
            OnSubtractClick();
        }

        private void oneButton_Click(object sender, RoutedEventArgs e)
        {
            OnOneClick();
        }

        private void twoButton_Click(object sender, RoutedEventArgs e)
        {
            OnTwoClick();
        }

        private void threeButton_Click(object sender, RoutedEventArgs e)
        {
            OnThreeClick();
        }

        private void multiplyButton_Click(object sender, RoutedEventArgs e)
        {
            OnMultiplyClick();
        }

        private void zeroButton_Click(object sender, RoutedEventArgs e)
        {
            OnZeroClick();
        }

        private void resultButton_Click(object sender, RoutedEventArgs e)
        {
            OnResultClick();
        }

        private void divideButton_Click(object sender, RoutedEventArgs e)
        {
            OnDivideClick();
        }

        private void ShowLogButton_Click(object sender, RoutedEventArgs e)
        {
            OnShowLogClick();
        }

        private void LogSave_Click(object sender, RoutedEventArgs e)
        {
            OnSaveToFileClick();
        }

        private void LoggerSwitcher_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
        {
            OnChooseLogClick(LoggerSwitcher.SelectedIndex);
        }
    }
}
